package pipe;

import interfaces.IOable;
import interfaces.Writeable;
import interfaces.Readable;

import java.io.StreamCorruptedException;

public class Pipe<T> implements IOable<T, T>{
    private Readable<T> in;
    private Writeable<T> out;
    
    public void setIn(Readable<T> in) {
        this.in = in;
    }

    public void setOut(Writeable<T> out) {
        this.out = out;
    }

    @Override
    public T read() throws StreamCorruptedException {
        return this.in.read();
    }

    @Override
    public void write(T value) throws StreamCorruptedException {
        this.out.write(value);
    }
}
